package utiles_isi;


import java.text.ParseException;

public class isi_util {
	
	public static String CampoTexto(String cad_,int pos_,String separator){
		
		if(cad_.contains(separator)){
			String [] campos=cad_.split(separator);	
			if(campos.length>pos_) cad_=campos[pos_];
			
		}
		return cad_;
	}
	
	public static int CampoTextoInt(String cad_,int pos_,String separator){
		
		/*if(cad_.contains(separator)){
			String [] campos=cad_.split(separator);	
			if(campos.length>pos_) cad_=campos[pos_];
			
		}*/
		cad_=CampoTexto(cad_, pos_, separator);
		return isiParseInt(cad_);
	}
	
   public static double CampoTextoDouble(String cad_,int pos_,String separator){
		
		cad_=CampoTexto(cad_, pos_, separator);
		return isiParseDouble(cad_);
	}
	
	public static int isiParseInt(String i)
	{
	try 
	{
	return Integer.parseInt(i);
	}
	catch(NumberFormatException nfe)
	{
	return 0;
	}
	}
	
	public static double isiParseDouble(String i)
	{
	try 
	{
	return Double.parseDouble(i);
	}
	catch(NumberFormatException nfe)
	{
	return (double)0;
	}
	}
	
	public static boolean IntToBoolean(int i_){
		return ( (i_==0) );
	}
	
	public static int BooleanToInt(boolean i_){
		return(i_?1:0); 
	}
	//// valores estaticos
	
	public static int ErrorDato= -999999999;
	
	/////
	
	
}